package main.chapter2

fun main(args: Array<String>) {
    checkArgs(args)
    val arg1 = args[0].toInt()
    val arg2 = args[1].toInt()
    println("$arg1+$arg2=${sum(arg1, arg2)}")
    println(noNameFun(3))
}

fun checkArgs(args: Array<String>) {
    if (args.size < 2) {
        printUseHelp()
        //
        System.exit(0)
    }
}

fun printUseHelp() {
    println("请传入两个整形参数,例如1,2")
}

private fun sum(arg1: Int, arg2: Int): Int = arg1 + arg2
val noNameFun = fun(x: Int): Long {
    return x.toLong()
}
